<!DOCTYPE html>
<html>
	<head lang="en">
		<meta charset="UTF-8">
		<title>超市订单管理系统</title>
		<link type="text/css" rel="stylesheet" href="../css/style.css" />
		<link type="text/css" rel="stylesheet" href="../css/public.css" />
		<style>
			body{
				background-color: white;
			}
			#imgButton{
				border: none;
				background: none;
				-webkit-box-shadow: none;
				-moz-box-shadow: none;
				box-shadow: none;
			}
		</style>
	</head>
	<body>
		<div class="location">
			<strong>你现在所在的位置是:</strong>
			<span>订单管理页面 &gt;&gt; 订单添加页面</span>
		</div>
		<div class="providerAdd">
			<form id="billForm" name="billForm" method="post" action="">
				<input type="hidden" name="method" value="add">
				<div>
					<label for="imgButton">商品封面：</label><img width="200px" id="img"/>
					<input  type="file" name="imgButton" id="imgButton" onchange="upload()">
				</div>
				<div>
					<label for="billCode">订单编码：</label>
					<input required type="text" name="billCode" class="text" id="billCode" value="" validatestatus="false">
				</div>
				<div>
					<label for="productName">商品名称：</label>
					<input required type="text" name="productName" id="productName" value="">
					<font color="red">*</font>
				</div>
				<div>
					<label for="productUnit">商品单位：</label>
					<input required type="text" name="productUnit" id="productUnit" value="">
					<font color="red">*</font>
				</div>
				<div>
					<label for="productCount">商品数量：</label>
					<input required type="text" name="productCount" id="productCount" value="">
					<font color="red">*</font>
				</div>
				<div>
					<label for="totalPrice">总金额：</label>
					<input required type="text" name="totalPrice" id="totalPrice" value="" pattern="^[1-9][0-9]*$">
					<font color="red">*</font>
				</div>
				<div>
					<label>供应商：</label>
					<select name="providerId" id="pro_list">
						<option value="0">请选择</option>
					</select>
					<font color="red">*</font>
				</div>
				<div>
					<label>是否付款：</label>
					<input type="radio" name="isPayment" value="1" checked="checked">未付款
					<input type="radio" name="isPayment" value="2">已付款
				</div>
				<div class="providerAddBtn">
					<input type="submit" name="add" id="add" value="保存" onclick="checkBill('add')">
					<input type="button" id="back" name="back" value="返回" onclick="history.go(-1)">
				</div>
			</form>
		</div>
		<script src="../js/jquery-3.5.1.js"></script>
		<script src="../js/jquery.form.js"></script>
		<script src="../js/common.js"></script>
		<script>
			//加载供应商列表
			loadData_pro();

			//绑定表单提交事件
			$("form").submit(function () {
				var params={"imgSrc":$("#img").attr("src")};

				//用ajax方式提交表单
				$("form").ajaxSubmit({
					url:"../bill/addBill",
					type:"post",
					dataType:"json",
					data:params,
					success:function (result) {
						if (result.flag){
							alert(result.msg);
							location.href="bill_list.html";
						}else {
							alert(result.msg);
						}
					},
					error:function (jqxhr){
					alert("请求出错：" + jqxhr.status);
				},
				});

				//阻止继续
				return false;
			});



		</script>

	</body>
</html>
